/****************************************************************************

	COPYRIGHT(C) MAXSI SOFTWARE, JONAS 'SORTIE' TERMANSEN 2008, 2009, 2010

    This file is part of Maxsi Engine.

    Maxsi Engine is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Maxsi Engine is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Maxsi Engine. If not, see <http://www.gnu.org/licenses/>.

	*/ #include "MaxsiEngineContributors.h" /*

	If you modify this file, please enter your name below and provide contact
	information in MaxsiEngineContributors.h. For more information please see
	MaxsiEngineContributors.h.
	
	Contributors to this file:

	- Jonas 'Sortie' Termansen
	- [your name here]

	MaxsiEngine.dll
	A linkable version of Maxsi Engine

	MaxsiInstallScript.cpp
	Functions that execute install scripts, and interfaces for declaring
	functions that can be used by insall scripts.

****************************************************************************/

#include <windows.h>
#include "MaxsiEngine.h"

#ifndef MaxsiInstallScript_H
#define MaxsiInstallScript_H

namespace MaxsiEngine
{

	CLASSLINK MaxsiInstallScriptInput
	{
	public:
		List	Var;
		size_t	Size;
	public:
		char*	operator[]	( size_t					val		);
		void	operator=	( List						Input	);
		List	operator=	( MaxsiInstallScriptInput	Input	);
		List	operator()	(									){	return Var;}

		MaxsiInstallScriptInput	();
		MaxsiInstallScriptInput	(List Input);
	};
	#define MISInput MaxsiInstallScriptInput
	#define MISFUNCH(Name			) int Name (MISInput In)
	#define MISFUNC(Name,Permission) \
	class	MISFUNC_Register_##Name \
	{ \
	public: \
		MISFUNC_Register_##Name() \
		{ \
		MISFuncRegister( #Name , &Name , #Permission ); \
		} \
	} MISFUNC_Register_Instance_##Name; \
	int Name (MISInput In)

	#define MISINSTRUCTIONH(Name) int Name (char* p1, char* p2)
	#define MISINSTRUCTION(Name) int Name (char* p1, char* p2)
	struct	MISFuncS;
	struct	MISFuncP;
	struct	MISDataPool;
	struct	MISInstruction;
	struct	MISInstructionP;
	struct	MISCompiledScript;

	typedef int		(__cdecl* MISFunc)	(MISInput);
	typedef int		(__cdecl* MISInstructionFunc)	(char* p1, char* p2);
	typedef char*	MISPermission;
	LINK	bool			MISFuncRegister		(char* Name, MISFunc Pointer, MISPermission Permission);
	LINK	MISFunc			MISFuncGet			(char* Name, MISPermission Permission);
	LINK	int				MISRun				(char* Script, MISPermission Permission);

	struct MISFuncS
	{
		char*			Name;
		MISFunc			Pointer;
	};
	
	struct MISFuncP
	{
		char*			Name;
		List			Functions;
	};

	struct	MISDataPool
	{
		size_t	Length;
	};

	struct	MISCompiledScript
	{
		

	};

	struct MISInstructionP
	{
		MISDataPool*	DataPool;
		size_t			Offset;
	};

	struct MISInstruction
	{
		MISFunc			Function;
		char*			p1;
		char*			p2;
	};

	MISINSTRUCTIONH(MIS_LOADLIBRARY);

	MISINSTRUCTIONH(MIS_WTRINT);
	MISINSTRUCTIONH(MIS_WTRUINT);
	MISINSTRUCTIONH(MIS_WTRSTR);
	
	MISINSTRUCTIONH(MIS_ADDINT);
	MISINSTRUCTIONH(MIS_ADDUINT);

	MISINSTRUCTIONH(MIS_SUBINT);
	MISINSTRUCTIONH(MIS_SUBUINT);

	MISINSTRUCTIONH(MIS_MULINT);
	MISINSTRUCTIONH(MIS_MULUINT);

	MISINSTRUCTIONH(MIS_DIVINT);
	MISINSTRUCTIONH(MIS_DIVUINT);

	MISINSTRUCTIONH(MIS_STACKINT);
	MISINSTRUCTIONH(MIS_STACKUINT);

	MISINSTRUCTIONH(MIS_COPY);

}

#endif
